<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>vue</title>
    <script src='https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js'></script>
    <style>
        #overlay {
            background: rgba(0, 0, 0, 0.6);
            width: 100%;
            margin: auto;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }

        #center {
            background: #ffff;
            border-radius: 5px;
            /* 边框圆角 */
            padding-top: 15px;
            padding-left: 30px;
            padding-bottom: 15px;
            width: 290px;
            height: 160px;
            position: fixed;
            margin: auto;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
        }
    </style>
</head>

<body>
    <div id='app'>
        <button @click="isShow=true">show</button>

        <!-- 方案2：self -->
        <div id="overlay" v-show="isShow" @click="isShow=false">
        <!-- <div id="overlay" v-show="isShow" @click.self="isShow=false"> -->
            <!-- 方案1：stop -->
            <div id="center" @click.stop>
            <!-- <div id="center"> -->
                <div>用户名：<input type="text" /></div>
                <div>密码：<input type="password" /></div>
                <div>
                    <button>登录</button>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
    // bug: 点击表单输入内容，冒泡到父 div(overlay)，触发函数，隐藏
    let vm = new Vue({
        el: '#app',
        data: {
            isShow: false
        }
    });
</script>

</html>